package cn.stylefeng.guns.modular.single.controller;

import cn.stylefeng.guns.modular.single.entity.DiseaseType;
import cn.stylefeng.guns.modular.single.service.DiseaseTypeService;
import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigParam;
import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigTypeParam;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@ApiResource(
        name = "病种的接口"
)
public class DiseaseTypeController {
    @Resource
    private DiseaseTypeService service;
    @GetResource(
            name = "获取需要初始化的配置列表",
            path = {"/diseaseType/configList"}
    )
    public ResponseData<List<SysDict>> getInitConfigList(SysConfigTypeParam sysConfigTypeParam) {
        return new SuccessResponseData<>(this.service.getInitConfigs(sysConfigTypeParam));
    }
    @GetResource(
            name = "获取需要初始化的配置列表",
            path = {"/diseaseType/list"}
    )
    public ResponseData<List<DiseaseType>> getList(String diseaseCode) {
        return new SuccessResponseData<>(this.service.getDiseaseTypeList(diseaseCode));
    }
    @GetResource(
            name = "获取需要初始化的配置列表",
            path = {"/diseaseType/datalist"}
    )
    public ResponseData<List<DiseaseType>> datalist(String diseaseCode,String inNo) {
        return new SuccessResponseData<>(this.service.datalist(diseaseCode,inNo));
    }

    @GetResource(
            name = "获取需要数据",
            path = {"/diseaseType/detail"}
    )
    public ResponseData<DiseaseType> detail(int id) {
        return new SuccessResponseData<>(this.service.detail(id));
    }
    @PostResource(
            name = "编辑参数配置",
            path = {"/diseaseType/edit"}
    )
    public ResponseData<?> edit(@RequestBody @Validated({BaseRequest.edit.class}) DiseaseType diseaseType, HttpServletRequest request) {
        this.service.edit(diseaseType);
        return new SuccessResponseData<>();
    }
    @GetResource(
            name = "分页查询配置列表",
            path = {"/diseaseType/page"}
    )
    public ResponseData<PageResult<DiseaseType>> page(@Validated({BaseRequest.page.class}) SysConfigParam sysConfigParam) {
        return new SuccessResponseData<>(this.service.findPage(sysConfigParam));
    }
}
